<?php
/**
 * english version
 * @author li.junfu
 */
require_once "../".$GLOBALS["local"]."/order.php";
require_once "../".$GLOBALS["local"]."/myaccount.php";

class Order {
	
    public static $normalWeightFee = 8;
    public static $SFWeightFee = 20;
    public static $EMSWeightFee = 20;
	
    public static function getOrderStatusList(){
        $orderstatus = array(
        			0 =>UNPAID,
                    1 =>PENDING,
                    2 =>PROCESSING,
                    3 =>COMPLETED,
                    4 =>CANCELED 
                  );
         return $orderstatus;
    }
    
    public static function getOrderStatus($key){
        $orderstatus = Order::getOrderStatusList();
        return $orderstatus[$key];
    }
    
    public static  function getStateNameList(){
    	$cantonnamelist = array(
    							'AZ'=>ARIZONA,
    							'CA'=>CALIFORNIA,
    							'NV'=>NEVADA,
    							'FL'=>FLORIDA,
    							'AL'=>ALABAMA,
    							'AK'=>ALASKA,
    							'AR'=>ARKANSAS,
    							'CO'=>COLORADO,
    							'CT'=>CONNECTICUT,
    							'DE'=>DELAWARE,
    							'DC'=>DISTRICTOFCOLUMBIA,
    							'GA'=>GEORGIA,
    							'HI'=>HAWAII,
    							'ID'=>IDAHO,
    							'IL'=>ILLINOIS,
    							'IN'=>INDIANA,
    							'KA'=>KANSAS,
    							'KY'=>KENTUCKY,
    							'LA'=>LOUISIANA,
    							'ME'=>MAINE,
    							'MD'=>MARYLAND,
    							'MA'=>MASSACHUSETTS,
    							'MI'=>MICHIGAN,
    							'MN'=>MINNESOTA,
    							'MS'=>MISSISSIPPI,
    							'MO'=>MISSOURI,
    							'MT'=>MONTANA,
    							'NE'=>NEBRASKA,
    							'NH'=>NEWHAMPSHIRE,
    							'NJ'=>NEWJERSEY,
    							'NY'=>NEWYORK,
    							'NC'=>NORTH,
    							'ND'=>NORTHDAKOTA,
    							'OH'=>OHIO,
    							'OK'=>OKLAHOMA,
    							'OR'=>OREGON,
    							'PA'=>PENNSYLVANIA,
    							'RI'=>RHODEISLAND,
    							'SC'=>SOUTHCAROLINA,
    							'SD'=>SOUTHDAKOTA,
    							'TN'=>TENNESSEE,
    							'TX'=>TEXAS,
    							'UT'=>UTAH,
    							'VT'=>VERMONT,
    							'VA'=>VIRGINIA,
    							'WA'=>WASHINGTON,
    							'WV'=>WESTVIRGINIA,
    							'WI'=>WISCONSIN,
    							'WY'=>WYOMING,
    							'IA'=>IOWA,
    							'NM'=>NEWMEXICO
    			);
    	return $cantonnamelist;
    }
    
    public static function getStateName($key){
    	$cantonnames = Order::getStateNameList();
        if(!empty ($cantonnames[$key]) && isset ($cantonnames[$key])){
            return $cantonnames[$key];
        }
        return $key;
    }
    
    public static function getShippingExpectList(){
        $expect = array(
                    1 =>AM,
                    2 =>PM,
                    3 =>NIGHT,
                    4 =>NOLIMIT
                 );
        return $expect;
    }
    
    public static function getShippingExpect($key){
    	$shippingexpect = Order::getShippingExpectList();
    	return $shippingexpect[$key];
    }
    
    public static function getMonthList(){
        $monthList = array(
					'01' => JANUARY,
					'02' => FEBRUARY,
					'03' => MARCH,
					'04' => APRIL,
					'05' => MAY,
					'06' => JUNE,
					'07' => JULY,
					'08' => AUGUST,
					'09' => SEPTEMBER,
					'10' => OCTOBER,
					'11' => NOVEMBER,
					'12' => DECEMBER
                  );
         return $monthList;
    }

    public static function getCardTypeList(){
        $orderstatus = array(
                    "MC" =>MASTERCARD, 
                    "VS" =>VISA, 
                    "DS" =>DISCOVER, 
                    "AE" =>AMEX 
                  );
         return $orderstatus;
    }

    public static function getCardType($key){
        $cardType = Order::getCardTypeList();
        return $cardType[$key];
    }
    
    public static function getCountryNameList(){
        $countryList = array(
                                "CN" => "China",
                                "US" => "United States"
                );
        return $countryList;
    }
    
    public static function getDefaultChequeRuleList(){
    	$chequeRuleList = array(
                                    1 => CHEQUERULE1,
				                    11 => CHEQUERULE11,
				                    12 => CHEQUERULE12,
				                    13 => CHEQUERULE13,
				                    14 => CHEQUERULE14,
				                    15 => CHEQUERULE15,
				                    2 => CHEQUERULE2,
				                    21 => CHEQUERULE21,
				                    22 => CHEQUERULE22,
				                    23 => CHEQUERULE23,
				                    24 => CHEQUERULE24,
				                    25 => CHEQUERULE25,                                                                                                    
				                    3 => CHEQUERULE3,
    	       );
    	return $chequeRuleList;
    }
    
    public static function getDefaultChequeRule($key){
        $chequeRule = Order::getDefaultChequeRuleList();
        return $chequeRule[$key];
    }
    
    public static function getDefaultChequeRuleNameList(){
    	$chequeRuleList = array(
                                    1 => CHEQUERULENAME1,
				                    11 => CHEQUERULENAME11,
				                    12 => CHEQUERULENAME12,
				                    13 => CHEQUERULENAME13,
				                    14 => CHEQUERULENAME14,
				                    15 => CHEQUERULENAME15,
				                    2 => CHEQUERULENAME2,
				                    21 => CHEQUERULENAME21,
				                    22 => CHEQUERULENAME22,
				                    23 => CHEQUERULENAME23,
				                    24 => CHEQUERULENAME24,
				                    25 => CHEQUERULENAME25,                                                                                                    
				                    3 => CHEQUERULENAME3,
    	       );
    	return $chequeRuleList;
    }
    
    public static function getDefaultChequeRuleName($key){
        $chequeRule = Order::getDefaultChequeRuleNameList();
        return $chequeRule[$key];
    }
    
    /**
     * Get order status (front)
     *
     * @author by M.Wang
     * @param int $int_key
     * @return array|string
     */
    public static function getOrderStatusFront( $int_key = null ){
    	$arr_status = array(
			0 => ORDERSSTATUS0,
			1 => ORDERSSTATUS1,
			2 => ORDERSSTATUS2,
			3 => ORDERSSTATUS3,
			4 => ORDERSSTATUS4,
			5 => ORDERSSTATUS5,
			6 => ORDERSSTATUS6,
			7 => ORDERSSTATUS7,
			11 => ORDERSSTATUS11,
			12 => ORDERSSTATUS12,
			13 => ORDERSSTATUS13,
			14 => ORDERSSTATUS14,
			15 => ORDERSSTATUS15,
			16 => ORDERSSTATUS16,
			17 => ORDERSSTATUS17,
			21 => ORDERSSTATUS21,
			22 => ORDERSSTATUS22,
			23 => ORDERSSTATUS23,
			24 => ORDERSSTATUS24,
			25 => ORDERSSTATUS25,
			26 => ORDERSSTATUS26,
			27 => ORDERSSTATUS27
    	);
    	if( empty( $int_key ) )
    	   return $arr_status;
    	else
    	   return $arr_status[$int_key];
    }
    
    /**
     * Get orders.shipping_expect setting
     *
     * @author by M.Wang
     * @param int $int_index
     * @return array|string
     */
    public static function getOrderShippingExpect( $int_index = null ){
    	$arr_ships = array(
           1 => OSHIPEXPECT1, 
           2 => OSHIPEXPECT2, 
           3 => OSHIPEXPECT3, 
           4 => OSHIPEXPECT4, 
           5 => OSHIPEXPECT5, 
           6 => OSHIPEXPECT6
        );
        if( empty( $int_index ) )
            return $arr_ships;
        else
            return $arr_ships[$int_index];
    }
    
    /**
     * Get orders.payment_method setting
     *
     * @author by M.Wang
     * @param int $int_index
     * @return array|string
     */
    public static function getOrderPaymentMethod( $int_index = null ){
    	$arr_payments = array(
           1 => OPAYMENTMETHOD1,
           2 => OPAYMENTMETHOD2,
           3 => OPAYMENTMETHOD3,
           4 => OPAYMENTMETHOD4,
           5 => OPAYMENTMETHOD5,
           11 => OPAYMENTMETHOD11,
           12 => OPAYMENTMETHOD12,
           13 => OPAYMENTMETHOD13,
           14 => OPAYMENTMETHOD14,
           15 => OPAYMENTMETHOD15,
           16 => OPAYMENTMETHOD16,
           17 => OPAYMENTMETHOD17
        );
        if( empty( $int_index ) )
            return $arr_payments;
        else
            return $arr_payments[$int_index];
    }
    
    /**
     * Get normal payment province price order by weight
     */
    public static function getNormalPaymentProvinceFeeList(){
        $normalPaymentProvinceFee = array(
                    1 =>3, 
                    837 =>8, 
                    968 =>8, 
                    816 =>8, 
                    2263 =>10,
                    2770 =>10, 
                    3115 =>10, 
                    3279 =>10, 
                    3217 =>10,
                    2669 =>10,
                    3306 =>12,
                    2916 =>15,
                    0 =>10
                  );
         return $normalPaymentProvinceFee;
    }

    public static function getNormalPaymentProvinceFee($key){
        $paymentProvinceFee = Order::getNormalPaymentProvinceFeeList();
        return $paymentProvinceFee[$key];
    }
    
    /**
     * Get SF payment province price order by weight
     */
    public static function getSFPaymentProvinceFeeList(){
        $SFPaymentProvinceFee = array(
                    1 =>2, 
                    837 =>10, 
                    968 =>10, 
                    816 =>10, 
                    2419 =>10, 
                    2461 =>10, 
                    2263 =>10,
                    2770 =>10, 
                    3115 =>10, 
                    3279 =>10, 
                    3217 =>10,
                    2669 =>10,
                    0 =>10
                  );
         return $SFPaymentProvinceFee;
    }

    public static function getSFPaymentProvinceFee($key){
        $paymentProvinceFee = Order::getSFPaymentProvinceFeeList();
        return $paymentProvinceFee[$key];
    }
    
    /**
     * Get EMS payment province price order by weight
     */
    public static function getEMSPaymentProvinceFeeList(){
        $EMSPaymentProvinceFee = array(
                    1 =>6, 
                    837 =>6, 
                    968 =>6, 
                    816 =>6, 
                    2419 =>9, 
                    2461 =>9, 
                    2263 =>9,
                    2770 =>9, 
                    3279 =>9, 
                    3217 =>9, 
                    2669 =>9, 
                    3115 =>15,
                    3306 =>15,
                    2916 =>15,
                    0 =>15
                  );
         return $EMSPaymentProvinceFee;
    }

    public static function getEMSPaymentProvinceFee($key){
        $paymentProvinceFee = Order::getEMSPaymentProvinceFeeList();
        return $paymentProvinceFee[$key];
    }
    
    /**
     * Set ship rule 
     */
    public static function getShipRuleList(){
        $shipRuleList = array(
                    1 =>FIXEDFEE, 
                    2 =>WEIGHTFEE, 
                    3 =>FREEFEE
                  );
         return $shipRuleList;
    }

    public static function getShipRule($key){
        $shipFee = Order::getShipRuleList();
        return $shipFee[$key];
    }
    
    /**
     * 得到订单运输方式
     * 如：高校货到付款
     */
    public static function getShippingMethodList(){
        $shipMethodList = array(
                    1 =>OSHIPEXPECT1,
                    2 =>OSHIPEXPECT2,
                    3 =>OSHIPEXPECT3,
                    4 =>OSHIPEXPECT4,
                    5 =>OSHIPEXPECT5,
                    6 =>OSHIPEXPECT6
                  );
         return $shipMethodList;
    }

    public static function getShippingMethod($key){
        $shipMethod = Order::getShippingMethodList();
        return $shipMethod[$key];
    }
    
    /**
     * 得到付款方式
     * 如：支付宝
     */
    public static function getPaymentMethodList(){
        $payMethod = array(
                    1 =>OPAYMENTMETHOD1,
                    2 =>OPAYMENTMETHOD2,
                    3 =>OPAYMENTMETHOD3,
                    4 =>OPAYMENTMETHOD4,
                    5 =>OPAYMENTMETHOD5,
                    11 =>OPAYMENTMETHOD11,
                    12 =>OPAYMENTMETHOD12,
                    13 =>OPAYMENTMETHOD13,
                    14 =>OPAYMENTMETHOD14,
                    15 =>OPAYMENTMETHOD15,
                    16 =>OPAYMENTMETHOD16,
                    17 =>OPAYMENTMETHOD17
                 );
       return $payMethod;
    }
    
    public static function getPaymentMethod($key){
        $paymentmethod = Order::getPaymentMethodList();
        return $paymentmethod[$key];        
    }

    
    
}